package ferp.center.server.servlet;

import ferp.center.network.RequestWhistAdd;
import ferp.center.server.Action;
import ferp.center.server.entity.Whist;

import javax.persistence.EntityManager;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * User: igorgok
 * Date: 12/5/12 9:47 AM
 */
public class WhistAdd extends HttpServlet
{
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {
    Action.execute(request, response, RequestWhistAdd.class, new Action.Write<RequestWhistAdd, Boolean>()
    {
      @SuppressWarnings("unchecked")
      public Boolean run(EntityManager em, RequestWhistAdd input) throws IOException
      {
        // do not look for Profile object, save reads
        Whist whist = new Whist(input);

        em.persist(whist);

        return Boolean.TRUE;
      }
    });
  }

  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
  {

  }
}
